package org.mogu.tools;

import org.mogu.db.DBhelper;
import org.mogu.service.InfoSync;
import org.mogu.staticvalue.Convert;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class UserUtil {
	
	public static void getUser(Context context){
		if(Convert.uname==null||Convert.upwd==null){
			getUserInfo(context);
		}
	}
	
	public static void getUserInfo(Context context){
		synchronized (InfoSync.class) {
	        SQLiteDatabase readdb = DBhelper.getDBHelper(context).getReadableDatabase();
	        Cursor activelist = readdb
					.rawQuery(
							"select username,password from activeuser order by isactive desc",
							null);
	        activelist.moveToFirst();
	        if(!activelist.isAfterLast()){
	        	Convert.uname=activelist.getString(0);
	            Convert.upwd=activelist.getString(1);
	        }
	        activelist.close();
	        readdb.close();
	        }
		
		
	}

}
